package net.lab1024.sa.admin.module.business.displayModelLayer.controller;

import net.lab1024.sa.admin.module.business.displayModelLayer.domain.form.DisplayModelLayerAddForm;
import net.lab1024.sa.admin.module.business.displayModelLayer.domain.form.DisplayModelLayerQueryForm;
import net.lab1024.sa.admin.module.business.displayModelLayer.domain.form.DisplayModelLayerUpdateForm;
import net.lab1024.sa.admin.module.business.displayModelLayer.domain.vo.DisplayModelLayerVO;
import net.lab1024.sa.admin.module.business.displayModelLayer.service.DisplayModelLayerService;
import net.lab1024.sa.base.common.domain.ValidateList;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import cn.dev33.satoken.annotation.SaCheckPermission;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.PageResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * 页面 Controller
 *
 * @Author 1
 * @Date 2025-07-04 09:28:47
 * @Copyright 1
 */

@RestController
@Tag(name = "页面")
public class DisplayModelLayerController {

    @Resource
    private DisplayModelLayerService displayModelLayerService;

    @Operation(summary = "分页查询 @author 1")
    @PostMapping("/displayModelLayer/queryPage")
    @SaCheckPermission("displayModelLayer:query")
    public ResponseDTO<PageResult<DisplayModelLayerVO>> queryPage(@RequestBody @Valid DisplayModelLayerQueryForm queryForm) {
        return ResponseDTO.ok(displayModelLayerService.queryPage(queryForm));
    }

    @Operation(summary = "添加 @author 1")
    @PostMapping("/displayModelLayer/add")
    @SaCheckPermission("displayModelLayer:add")
    public ResponseDTO<String> add(@RequestBody @Valid DisplayModelLayerAddForm addForm) {
        return displayModelLayerService.add(addForm);
    }

    @Operation(summary = "更新 @author 1")
    @PostMapping("/displayModelLayer/update")
    @SaCheckPermission("displayModelLayer:update")
    public ResponseDTO<String> update(@RequestBody @Valid DisplayModelLayerUpdateForm updateForm) {
        return displayModelLayerService.update(updateForm);
    }

    @Operation(summary = "批量删除 @author 1")
    @PostMapping("/displayModelLayer/batchDelete")
    @SaCheckPermission("displayModelLayer:delete")
    public ResponseDTO<String> batchDelete(@RequestBody ValidateList<Integer> idList) {
        return displayModelLayerService.batchDelete(idList);
    }

    @Operation(summary = "单个删除 @author 1")
    @GetMapping("/displayModelLayer/delete/{id}")
    @SaCheckPermission("displayModelLayer:delete")
    public ResponseDTO<String> batchDelete(@PathVariable Integer id) {
        return displayModelLayerService.delete(id);
    }

    @GetMapping("/displayModelLayer/listAll")
    public ResponseDTO<List<DisplayModelLayerVO>> listAll() {
        return ResponseDTO.ok(displayModelLayerService.listAll());
    }
}
